<template>
  <div>
    <template>
      <el-table
        :data="
          Order
            .filter(
              (data) =>
                !search ||
                data.m_Item5.toLowerCase().includes(search.toLowerCase())
            )
            .slice((currentPage - 1) * pagesize, currentPage * pagesize)
        "
        style="width: 100%;"
      >
        <el-table-column
          prop="m_Item5"
          label="电影名称"
          width="300"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="m_Item6" label="影厅" align="center">
        </el-table-column>
        <el-table-column label="座位" width="250" align="center">
        <template slot-scope="scope">
          <p>
            {{scope.row.m_Item1|seat}}
          </p>
        </template>
        </el-table-column>
        <el-table-column prop="m_Item4" label="用户ID" align="center">
        </el-table-column>
        <el-table-column prop="m_Item2" label="票价" width="250" align="center">
        </el-table-column>
        <el-table-column prop="m_Item3" label="开始时间" align="center">
        </el-table-column>
        
        <el-table-column align="center">
          <template slot="header" slot-scope="scope">
            <el-input
              v-model="search"
              size="mini"
              placeholder="输入关键字搜索"
            />
          </template>
        </el-table-column>
      </el-table>
    </template>
    <div style="text-align: center;margin-top: 30px;">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="total"
        @current-change="current_change"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      Order: [],
      total: 0,
      pagesize: 14,
      currentPage: 1,
      search:""
    };
  },
  mounted() {},
  methods: {
      current_change: function(currentPage) {
      this.currentPage = currentPage;
    },
  },filters: {
    seat: function(val) {
      var te = val.split("=");
      var res = "";
      var re = null;
      for (let i = 0; i < te.length; i++) {
        re = te[i].split(",");
        res += re[0] + "排" + re[1] + "座";
        if(i+1<te.length){
          res+=","
        }
      }
      return res
    }
  },
  created() {
    this.Ajax.get("api/Order/GetOrder").then((O) => {
      this.Order = O.data;
   
      this.total = O.data.length;
    });
  },
};
</script>
